function hrefBack() {
    history.go(-1);
}

function decodeQuery(){
    var search = decodeURI(document.location.search);
    return search.replace(/(^\?)/, '').split('&').reduce(function(result, item){
        values = item.split('=');
        result[values[0]] = values[1];
        return result;
    }, {});
}

$(document).ready(function(){
    var queryData = decodeQuery()
    var id = queryData['id'];
    $.get('/api/v1.0/house/'+ id, function(resp){
        if (resp.errno=='0'){
            $('.swiper-wrapper').html(template('swiper-teml', {imgs: resp.data.house.img_urls}));
            $('.detail-con').html(template('detail', {house: resp.data.house}))

            $('.house-price').html((resp.data.house.price)/100 + '元')

            var mySwiper = new Swiper ('.swiper-container', {
            loop: true,
            autoplay: 2000,
            autoplayDisableOnInteraction: false,
            pagination: '.swiper-pagination',
            paginationType: 'fraction'
        })
         if(resp.data.user_id != resp.data.house.user_id){
             $(".book-house").show().attr('href', '/booking.html?id=' + id)

         }

        }
    })



})